package com.huangpuweb.api.service.imp;

import com.huangpuweb.api.model.*;
import com.huangpuweb.api.service.GaApiService;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

@Service
public class GaApiServiceImp extends BaseGADataServiceImp implements GaApiService {


    @Override
    public List<GaRealLbs> getListGaRealLbs() {
        String sql="select * from hp_real_lbs_data where area_id in(11680,11779,11780,11782,11987,29483) order by stime desc limit 6";
        return getEntryList(sql,new GaRealLbsRowMapper(),new Object[]{});
    }

    @Override
    public List<GaJl> getListGaJl() {
        String sql="select * from hp_jl ";
        return getEntryList(sql,new GaJlRowMapper(),new Object[]{});
    }

    @Override
    public List<GaJq> getListGaJq(String today) {
        String sql="select * from hp_case_type where date=? ";
        return getEntryList(sql,new GaJqRowMapper(),new Object[]{today});
    }

    @Override
    public List<HpRealLbs> getLbsPoliceData() {
        String sql="select area,stime,average,`leave`,enter,area_id from (select area,stime,average,`leave`,enter,area_id from hp_real_lbs_data order by stime desc limit 416999)tmp group by area";
        return  getEntryList(sql, new RowMapper<HpRealLbs>() {
            @Override
            public HpRealLbs mapRow(ResultSet resultSet, int i) throws SQLException {
                HpRealLbs hr = new HpRealLbs();
                hr.setArea(resultSet.getString("area"));
                hr.setArea_id(resultSet.getString("area_id"));
                hr.setAverage(resultSet.getString("average"));
                hr.setStime(resultSet.getString("stime"));
                hr.setLeave(resultSet.getString("leave"));
                hr.setEnter(resultSet.getString("enter"));
                return hr;
            }
        },new Object[]{});
    }

    @Override
    public Integer getGaJqAllNum(String todayZero) {
        String sql="select count from hp_receiving_alarm_count where date=?";
        return queryInteger(sql,new Object[]{todayZero});
    }
}
